#ifndef FRIENDLIST_H
#define FRIENDLIST_H

#include <QWidget>
#include <QStandardItemModel>
#include<QAbstractItemView>
#include"QTableView"
#include"Socket/TCPSocket.h"
#include"Account/account.h"
namespace Ui {
class friendlist;
}

class friendlist : public QWidget
{
    Q_OBJECT

public:
    static friendlist *getinstance(){
        if(myfriendlist==nullptr)
            myfriendlist=new friendlist();
        return  myfriendlist;
    }

    ~friendlist();
    void GetTCPsocket(TCPSocket *Socket);
    friendlist(QString id,QString password);
  void  addfriend(QString id,QString name);
private slots:
    void on_chatbutton_clicked();
    void on_chatbutton_clicked2();
    void getIdAndName();
    void  getGroupIdAndName();
    void on_addfriend_clicked();

    void on_pushButton_clicked();

    void on_addgroup_clicked();

    void on_createButton_clicked();

private:
    explicit friendlist(QWidget *parent = nullptr);
    Ui::friendlist *ui;
    QTableView *tableView;
    QStandardItemModel *tableModel;
    QTableView *tableView2;
    QStandardItemModel *tableModel2;
    QString friendname;
    QString friendid;
    int myfriendnum=0;
    int groupnum=0;
    QMap<QString ,QString>  NameAndId;

    QMap<QString ,QString>  GroupNameAndId;
    TCPSocket *mysocket;
  static  friendlist *myfriendlist;
signals:
  void  sendid(QString id);
  void sendgroupid(QString id);
  void openchat(QString id);
  void  ToAddFriend();
  void  creategroup();
  void  sendOpenGroup(QString gid);
};

#endif // FRIENDLIST_H
